Debian 9 Stretch
Sponsored Link

Basic Authentication + PAM
2017/06/27
 
Limit accesses on specific web pages and use OS users for authentication with SSL connection.
[1] For example, set Basic Auth under the [/var/www/html/auth-pam] directory.
root@www:~#
apt -y install libapache2-mod-authnz-external pwauth
root@www:~#
vi /etc/apache2/sites-available/auth-pam.conf
# create new

AddExternalAuth pwauth /usr/sbin/pwauth
SetExternalAuthMethod pwauth pipe
<Directory /var/www/html/auth-pam>
    SSLRequireSSL
    AuthType Basic
    AuthName "PAM Authentication"
    AuthBasicProvider external
    AuthExternal pwauth
    require valid-user
</Directory>

root@www:~#
mkdir /var/www/html/auth-pam

root@www:~#
a2ensite auth-pam

Enabling site auth-pam.
To activate the new configuration, you need to run:
  service apache2 reload

root@www:~#
systemctl restart apache2
# create a test page

root@www:~#
vi /var/www/html/auth-pam/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page for PAM Auth
</div>
</body>
</html>
[2] Access to the test page with a Web browser on Client and authenticate with a user which is on OS.
[3] Just accessed.
 
Tweet